using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using Zwms.Data.BusinessObjects;
using Zwms.Data.Base;
using Zwms.Data.CommonObject;
using NHibernate.Criterion;
using System.Reflection;

namespace Zwms.Data.ManagerObjects
{
    public partial interface IBilInPlanBillDetailManager : IManagerBase<Zwms.Data.BusinessObjects.BilInPlanBillDetail, string>
    {
        // Get Methods
        BilInPlanBillDetail GetById(System.String iBPlanCode, System.String goodsCode);
    }

    partial class BilInPlanBillDetailManager : ManagerBase<Zwms.Data.BusinessObjects.BilInPlanBillDetail, string>, IBilInPlanBillDetailManager
    {
        #region Constructors

        public BilInPlanBillDetailManager()
            : base()
        {
        }
        public BilInPlanBillDetailManager(INHibernateSession session)
            : base(session)
        {
        }

        #endregion

        #region Get Methods

        public override BilInPlanBillDetail GetById(string id)
        {
            string[] keys = id.Split('^');

            if (keys.Length != 2)
                throw new Exception("Invalid Id for BilInPlanBillDetailManager.GetById");

            return GetById(keys[0], keys[1]);
        }
        public BilInPlanBillDetail GetById(System.String iBPlanCode, System.String goodsCode)
        {
            ICriteria criteria = Session.GetISession().CreateCriteria(typeof(BilInPlanBillDetail));

            criteria.Add(NHibernate.Criterion.Expression.Eq("IBPlanCode", iBPlanCode));
            criteria.Add(NHibernate.Criterion.Expression.Eq("GoodsCode", goodsCode));

            BilInPlanBillDetail result = (BilInPlanBillDetail)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
        }


        #endregion
    }
}